using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using Material.Entity;
using Material.Object;
using System.Configuration;

namespace Material.App
{
    public partial class FrmLogin : Form
    {
        private string connStr = ConfigurationManager.ConnectionStrings["dbconnection"].ToString();
        private TblUser tblUser;
        private TblUserEntity tblUserEntity;
        public static string UserID = string.Empty;
        public FrmLogin()
        {
            InitializeComponent();
            txtUserID.Focus();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            tblUserEntity = new TblUserEntity(connStr);
            tblUser = new TblUser();
            tblUser.UserID = txtUserID.Text.Trim();
            tblUser.Password = txtPassword.Text.Trim();

            tblUser = tblUserEntity.GetDataByUserID_Password(tblUser);

            if (tblUser.UserID!=null)
            {
                UserID = tblUser.UserID;
               
                this.Hide();
                FrmUtama frmUtama = new FrmUtama();
                frmUtama.Show();
            }
            else
            {
                MessageBox.Show("Maaf Anda tidak bisa login aplikasi..!!", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}